package com.amumu.drama.common.constant;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author sunzhuang
 * @date 2024/5/14 13:56
 * @slogan 天下风云出我辈, 一入代码岁月催
 * @desc 支付状态
 */
@Getter
public enum PayStatusEnum {
    /**
     * 支付状态
     */
    LOG(-1, "记录日志"),
    WAIT_PAY(0, "待支付"),
    PAYING(1, "支付中"),
    SUCCESS(2, "支付成功"),
    FAIL(3, "支付关闭"),
    REFUNDING(4, "退款中"),
    REFUND(5, "已退款"),
    REFUND_FAIL(6, "退款失败"),
    ;

    private Integer code;

    private String desc;

    PayStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private static final Map<Integer, PayStatusEnum> UNINDEX = Maps.uniqueIndex(Arrays.asList(values()), PayStatusEnum::getCode);

    public static PayStatusEnum getByCode(Integer code) {
        return UNINDEX.get(code);
    }

    public static List<PayStatusEnum> WAIT_PAY_AND_PAYING_LIST = Arrays.asList(WAIT_PAY, PAYING);

}
